package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.domain.vo.SelectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WmsWarehouseArea;
import com.ruoyi.system.service.IWmsWarehouseAreaService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仓库区域信息Controller
 *
 * @author ruoyi
 * @date 2025-06-13
 */
@RestController
@RequestMapping("/system/wmsWarehouseArea")
public class WmsWarehouseAreaController extends BaseController
{
    @Autowired
    private IWmsWarehouseAreaService wmsWarehouseAreaService;

    /**
     * 查询仓库区域信息列表
     */
    @SaCheckPermission("system:wmsWarehouseArea:list")
    @GetMapping("/list")
    public TableDataInfo<WmsWarehouseArea> list(WmsWarehouseArea wmsWarehouseArea, PageQuery pageQuery)
    {
        return wmsWarehouseAreaService.selectWmsWarehouseAreaList(wmsWarehouseArea,pageQuery);
    }

    /**
     * 导出仓库区域信息列表
     */
    /*@SaCheckPermission("system:wmsWarehouseArea:export")
    @Log(title = "仓库区域信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsWarehouseArea wmsWarehouseArea)
    {
        List<WmsWarehouseArea> list = wmsWarehouseAreaService.selectWmsWarehouseAreaList(wmsWarehouseArea);
        ExcelUtil<WmsWarehouseArea> util = new ExcelUtil<WmsWarehouseArea>(WmsWarehouseArea.class);
        util.exportExcel(response, list, "仓库区域信息数据");
    }*/

    /**
     * 获取仓库区域信息详细信息
     */
    @SaCheckPermission("system:wmsWarehouseArea:query")
    @GetMapping(value = "/{areaId}")
    public R<WmsWarehouseArea> getInfo(@PathVariable("areaId") Long areaId)
    {
        return R.ok(wmsWarehouseAreaService.selectWmsWarehouseAreaByAreaId(areaId));
    }

    /**
     * 新增仓库区域信息
     */
    @SaCheckPermission("system:wmsWarehouseArea:add")
    @Log(title = "仓库区域信息", businessType = BusinessType.INSERT)
    @PostMapping
    public R<Void> add(@RequestBody WmsWarehouseArea wmsWarehouseArea)
    {
        return toAjax(wmsWarehouseAreaService.insertWmsWarehouseArea(wmsWarehouseArea));
    }

    /**
     * 修改仓库区域信息
     */
    @SaCheckPermission("system:wmsWarehouseArea:edit")
    @Log(title = "仓库区域信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public R<Void> edit(@RequestBody WmsWarehouseArea wmsWarehouseArea)
    {
        return toAjax(wmsWarehouseAreaService.updateWmsWarehouseArea(wmsWarehouseArea));
    }

    /**
     * 删除仓库区域信息
     */
    @SaCheckPermission("system:wmsWarehouseArea:remove")
    @Log(title = "仓库区域信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{areaIds}")
    public R<Void> remove(@PathVariable Long[] areaIds)
    {
        return toAjax(wmsWarehouseAreaService.deleteWmsWarehouseAreaByAreaIds(areaIds));
    }

    /**
     * 查询列表
     */
    @SaCheckPermission("system:wmsWarehousec:list")
    @GetMapping("/getWarehouseAreaSelect")
    public R<List<SelectVo>> getWarehouseAreaSelect(){
        return R.ok(wmsWarehouseAreaService.getWarehouseAreaSelect());
    }

    /**
     * 根据仓库信息来获取仓库区域信息
     */
    @SaCheckPermission("system:wmsWarehousec:list")
    @GetMapping("/getWarehouseAreaSelectByWarehouseId")
    public R<List<SelectVo>> getWarehouseAreaSelectByWarehouseId(@RequestParam(required = false) Long warehouseId){
        return R.ok(wmsWarehouseAreaService.getWarehouseAreaSelectByWarehouseId(warehouseId));
    }
}
